package com.kuang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
public class ModelTest1 {

    @RequestMapping(value = "/m1/t1")
    public String test(HttpServletRequest request, HttpServletResponse response, Model model) {
        HttpSession session = request.getSession();
        String id = session.getId();
        model.addAttribute("msg", "通过");
        System.out.println(id);
        /*无视图解析器*/
//        return "/WEB-INF/jsp/test.jsp";//转发
//        return "forward:/WEB-INF/jsp/test.jsp";
//        return "redirect:/index.jsp";
        /*有视图解析器*/
        return "redirect:/t2";
    }

    @RequestMapping(value = "/m1/t2")
    public String test2(HttpServletRequest request, HttpServletResponse response, Model model) {
        HttpSession session = request.getSession();
        String id = session.getId();
        model.addAttribute("msg", "通过2");
        System.out.println(id);
        /*无视图解析器*/
//        return "/WEB-INF/jsp/test.jsp";//转发
//        return "forward:/WEB-INF/jsp/test.jsp";
//        return "redirect:/index.jsp";
        /*有视图解析器*/
        return "test";
    }


}
